package com.atiguigu.rabbitmq.five;

import com.atiguigu.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

public class EmitLog {
    public static final String EXCHANGE_NAME = "logs";
    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitMqUtils.getChannel();
        //声明交换机名、扇出（fanout）类型
        channel.exchangeDeclare(EXCHANGE_NAME,"fanout");
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            String message= scanner.next();
            //消息发送到交换机通过rountingKey绑定的队列
            channel.basicPublish(EXCHANGE_NAME,"",null,message.getBytes("UTF-8"));
        }

    }
}
